package com.niit.bc.util.web;

/*
 * 封装分页信息
 */
public class PageUtil {
    private int pageSize;
    private int pageCount;
    private int rowCount;
    private int pageCurr = 1;
    private int startCount;

    public PageUtil(int pageSize, int rowCount) {
        this.pageSize = pageSize;
        this.rowCount = rowCount;
    }

    public int getPageSize() {
        if (rowCount != 0 && rowCount < pageSize) {
            pageSize = rowCount;
        }
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }

    public int getPageCurr() {
        return pageCurr;
    }

    public void setPageCurr(int pageCurr) {
        this.pageCurr = pageCurr;
    }

    public int getStartCount() {
        int startCount = pageSize * (pageCurr - 1);
        return startCount;
    }

    public int getPageCount() {
        int pageCount = 0;
        if (rowCount % pageSize == 0) {
            pageCount = rowCount / pageSize;
        } else {
            pageCount = rowCount / pageSize + 1;
        }
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

}
